import java.util.Scanner;

public class Solution {
    public int removeElement(int[] nums, int val) {
        int n = nums.length;
        int left = 0;
        for (int right = 0; right < n; right++) {
            if(nums[right] != val){
                nums[left] = nums[right];
                left++;
            }
        }
        return left;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while(scanner.hasNextInt()){
            int size = scanner.nextInt();
            int[] array = new int[size];
            for (int i = 0; i < array.length; i++) {
                array[i] = scanner.nextInt();
            }
            int vals = scanner.nextInt();
            Solution solution = new Solution();
            int newsize = solution.removeElement(array,vals);
            for (int i = 0; i < newsize; i++) { // 根据返回值打印数组
                System.out.print(array[i] + " ");
            }
        }
    }
}